package leetcode.top100;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/10/22 8:22 PM
 * @description：https://leetcode.cn/problems/container-with-most-water/
 */
public class _011_盛最多水的容器 {
    @Test
    public void test() {
        System.out.println(new Solution().maxArea(new int[]{1,0,0,0,0,0,0,2,2}));
    }

    class Solution {
        public int maxArea(int[] height) {
           int l = 0;
           int r = height.length - 1;
           int max = 0;
           while (l < r) {
               int high = height[l] > height[r] ? height[r--] : height[l++];
               max = Math.max(max, (r - l + 1) * high);
           }
           return max;
        }
    }
}
